const mintWebpackPlugin = require('mint-webpack-plugin');
const reactAppRewirePostCSS = require('react-app-rewire-postcss');
const pxtorem = require('postcss-pxtorem');

module.exports = function override(config, env) {

  reactAppRewirePostCSS(config, {
    plugins: [
      pxtorem({
        rootValue: 37.5,
        unitPrecision: 2,
        propList: ['*']
      }),
    ]
  });


  // 生产环境打包上传静态资源文件至CDN
  if (env === 'production') {
    config.plugins = (config.plugins || []).concat([
      new mintWebpackPlugin.qiniuPlugin(),
    ]);
  }

  return config;
}
